package com.jieli.bt.att.demo

import com.jieli.bt.att.tool.ble.interfaces.IBtScanCallback
import com.jieli.bt.att.tool.ble.model.ScanDeviceInfo
import com.jieli.bt.att.tool.scan.BtScanner

/**
 * ScanDemo
 * @author zqjasonZhong
 * @since 2025/3/31
 * @email zhongzhuocheng@zh-jieli.com
 * @desc 扫描设备示例
 */
class ScanDemo {

    fun scanATTDevice() {
        //初始化蓝牙扫描器对象
        val btScanner = BtScanner.getInstance()
        //扫描设备
        //timeout --- 扫描超时限制
        //callback --- 扫描事件回调
        btScanner.startScan(30 * 1000L, object : IBtScanCallback {
            override fun onAdapterChange(bEnabled: Boolean) {
                //回调蓝牙开关状态
            }

            override fun onDiscoveryState(bStart: Boolean) {
                //回调扫描设备状态
            }

            override fun onDiscoveryDevice(scanDeviceInfo: ScanDeviceInfo?) {
                //回调搜索到的设备
            }

            override fun onDiscoveryFail(code: Int, message: String?) {
                //回调搜索设备失败
            }
        })
    }
}